const errorHandler = (err: any, dispatch?: any) => {
    console.groupCollapsed('%c ERROR ', 'background:#f00;color:#fff;padding:4px;');
    console.log(err);
    console.groupEnd();
    if (dispatch) {
        dispatch({ type: 'ERROR', payload: err });
    }
    if (err && err.custom) {
        const { code, msg, resonCode } = err;
        console.log(code, msg, resonCode);
    }
};

export default errorHandler;
